<template>
  <component  v-if="rOptions.length" v-model="reValue" ref="customizeSelectRef" :is="h(ElSelect,{...$attrs,...props,ref:bindExposed},$slots)" @change="$forceUpdate()" @input="$forceUpdate()">
<!--
    <el-option v-if="true" ref="optionsRef" :key="item.value" v-for="(item,index) in rOptions" :label="item.text" :value="item.value" @change="$forceUpdate()" @input="$forceUpdate()"></el-option>
-->
    <component v-for="(item,index) in rOptions" :is="h(ElOption,{...item},$slots)"></component>
<!--    <component :is="h(ElOption,{...$attrs,...props,ref:bindOptions},$slots)"  :key="item.value" v-for="(item,index) in rOptions" :label="item.text" :value="item.value"></component>-->
  </component>
</template>

<script lang="ts" setup>

import {getCurrentInstance, h, onMounted, reactive, ref, watch} from "vue";
import {ElMessage, ElOption, ElSelect} from "element-plus";
import {type ICustomizeSelectProps} from "@/components/plugs/form/DialogFormInterface";
import service from "@/utils/request";

const props = defineProps<Partial<ICustomizeSelectProps>>();
const vm:any = getCurrentInstance();
const {url,textFiled,valueField,defaultValue,selectedChange} = props;
const oldValue = defaultValue;
const reValue:any = ref(Number(-3));
const optionsRef = reactive([]);
const customizeSelect:any = ref(null);
const rOptions:any = reactive([]);
const customizeSelectRef = ref(null);
let resource:[] = [];
let selectProxy!:any;

const bindExposed = (instance:any) => {
  vm.exposed = instance || {};
  vm.exposeProxy = instance || {};
  selectProxy = instance;
  console.log(selectProxy);
}

const getDicData = function (){
  service.get(<string>url ).then(

      (respone:any) => {
        debugger;
        const dicData = respone.data.data;
        resource = dicData;
        for(const item of dicData){
          rOptions.push({
            "text": item[<string>textFiled],
            "value":Number(item[<string>valueField])
          });
        }
      }).catch((error:any) => {
    ElMessage.error("请求字典表数据失败：" + error);
  }).finally(() => {
  });
}
getDicData();


</script>

<style scoped>

</style>